package top.kaoshanji.p1ch05g.services;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import top.kaoshanji.p1ch05g.model.Comment;
import top.kaoshanji.p1ch05g.processors.CommentProcessor;

/**
 * 代码清单-p1ch05g-105页a：使用CommentProcessor作为原型bean
 * @author kaoshanji
 * ^_^
 * create time 2025/4/27 22:34
 */
@Service
public class CommentService {

    @Autowired
    private ApplicationContext applicationContext;

    public void sendComment(Comment comment) {
        CommentProcessor processor = applicationContext.getBean(CommentProcessor.class);

        processor.setComment(comment);
        processor.processComment(comment);
        processor.validateComment(comment);

        comment = processor.getComment();

        /// ////

    }

}
